package com.fms.model.domain;

import java.util.Calendar;

import junit.framework.TestCase;

public class FlowSheetTest extends TestCase
{
	public void testDateRound()
	{
		FlowSheet sheet = new FlowSheet("");
		
		
		Calendar c = Calendar.getInstance();
		
		c.set(Calendar.MINUTE, 4);
		
		sheet.setDate(c);
		assertTrue(sheet.getFirstReadingTime().get(Calendar.MINUTE) == 10);	
		
	}
	
	public void testDateRoundNine()
	{
		FlowSheet sheet = new FlowSheet("");
		
		
		Calendar c = Calendar.getInstance();
		
		c.set(Calendar.MINUTE, 11);
		
		sheet.setDate(c);
		assertTrue(sheet.getFirstReadingTime().get(Calendar.MINUTE) == 20);	
		
	}
	
	public void testDateRoundFiftyFour()
	{
		FlowSheet sheet = new FlowSheet("");
		
		
		Calendar c = Calendar.getInstance();
		
		c.set(Calendar.MINUTE, 49);
		c.set(Calendar.HOUR, 1);
		
		sheet.setDate(c);
		assertTrue(sheet.getFirstReadingTime().get(Calendar.MINUTE) == 55);	
		assertTrue(sheet.getFirstReadingTime().get(Calendar.HOUR) == 1);	
		
	}
	
	public void testDateRoundFiftyNine()
	{
		FlowSheet sheet = new FlowSheet("");
		
		
		Calendar c = Calendar.getInstance();
		
		c.set(Calendar.MINUTE, 59);
		c.set(Calendar.HOUR, 1);
		
		sheet.setDate(c);
		assertTrue(sheet.getFirstReadingTime().get(Calendar.MINUTE) == 5);	
		assertTrue(sheet.getFirstReadingTime().get(Calendar.HOUR) == 2);	
		
	}
	
	
	public void testGetReadingLaterOne()
	{
		FlowSheet sheet = new FlowSheet("");
		
		
		Calendar c = Calendar.getInstance();
		
		c.set(Calendar.MINUTE, 59);
		c.set(Calendar.HOUR, 1);
		
		sheet.setDate(c);
		assertTrue(sheet.getReadingTime(1).get(Calendar.MINUTE) == 35);	
		assertTrue(sheet.getReadingTime(1).get(Calendar.HOUR) == 2);
		
		
	}
	
	public void testGetReadingLaterTwo()
	{
		FlowSheet sheet = new FlowSheet("");
		
		
		Calendar c = Calendar.getInstance();
		
		c.set(Calendar.MINUTE, 59);
		c.set(Calendar.HOUR, 1);
		
		sheet.setDate(c);
		assertTrue(sheet.getReadingTime(2).get(Calendar.MINUTE) == 5);	
		assertTrue(sheet.getReadingTime(2).get(Calendar.HOUR) == 3);
		
		
	}
	
	public void testGetReadingLaterZero()
	{
		FlowSheet sheet = new FlowSheet("");
		
		
		Calendar c = Calendar.getInstance();
		
		c.set(Calendar.MINUTE, 59);
		c.set(Calendar.HOUR, 1);
		
		sheet.setDate(c);
		assertTrue(sheet.getReadingTime(0).get(Calendar.MINUTE) == 5);	
		assertTrue(sheet.getReadingTime(0).get(Calendar.HOUR) == 2);
		
		
	}
	
	public void testGetEndTime()
	{
		FlowSheet sheet = new FlowSheet("");
		
		
		Calendar c = Calendar.getInstance();
		
		c.set(Calendar.MINUTE, 0);
		c.set(Calendar.HOUR, 2);
		
		sheet.setDate(c);
		assertTrue(sheet.getEndTime().get(Calendar.MINUTE) == 45);	
		assertTrue(sheet.getEndTime().get(Calendar.HOUR) == 4);
		
		
	}
}
